package com.zit.dao;

import java.util.List;

import org.hibernate.Session;

import com.zit.entity.Dept;
import com.zit.entity.Teacher;

/**
 * 部门
 * @author ZengXueQin
 *
 */
public class DeptDAO extends BaseDAO {
	
	/**
	 * 查询部门：
	 * @param s
	 * @return
	 */
	public List<Dept> showDeptAndTeacher(Session s){
		return s.createQuery("from Dept dept join fetch dept.teacher t").list();
	}
	
	
  /**
   * 查询教师：
   * @param s
   * @return
   */
	public List<Teacher> selectTeacher(Session s){
		return s.createQuery("from Teacher teacher ").list();
	}
	
	
	/**
	 * 添加部门
	 * @param dept
	 * @param s
	 */
	public void addDept(Dept dept,Session s){
		s.save(dept);
	}
	
	/**
	 * 显示教师：
	 * @param id
	 * @param s
	 * @return
	 */
	public List<Dept> showTeacher(int id,Session s){
		return s.createQuery("from Dept dept join fetch dept.Teacher t where dept.teacher.id=:id ").setParameter("id", id).list();
	}
	
}
